#ifndef _VL_STRUCTURE_EXCEPTION__H_
#define _VL_STRUCTURE_EXCEPTION__H_

#include <cstdarg>
#include <string>

namespace VL {

/**
 * @Author: CimZzz
 * @Date: 2023-06-09 14:13:54
 * 
 * 结构容器异常类
 */
class VLStructureException {
public:
	explicit VLStructureException(const std::string& msg): message(msg) {};
	explicit VLStructureException(const char* msg, ...): message("") {
		va_list va, va2;
		va_start(va, msg);
		va_copy(va2, va);
		int size = ::vsnprintf(nullptr, 0, msg, va2);
		va_end(va2);
		char buf[size + 1];
		::vsnprintf(buf, size + 1, msg, va);
		buf[size] = '\0';
		va_end(va);
		this->message = buf;
	};

	const char * getMessage() const {
		return this->message.c_str();
	};

private:
	std::string message;
};

}

#endif // end _VL_STRUCTURE_EXCEPTION__H_